package Annotation.DataBase;

import java.sql.ResultSet;
import java.sql.SQLException;

public class MySQLCommand {

	private ResultSet rs = null;
	private MySQLConnection c = null;
	
	
	/**
	 * Responsible for Insert, Update, Delete action (didn't need to close DataBase)
	 * @param sql
	 */
	public void executeSQL(String sql){
		//System.out.println("come ime!!");
		c=new MySQLConnection();
		c.BuildConnection();
		c.commond(sql);
		c.closeConnection();
	}
	
	
	/**
	 * Responsible for Select action (Remember to close DataBase)
	 * @param sql
	 * @return
	 */
	public ResultSet selectSQL(String sql){
		c=new MySQLConnection();
		c.BuildConnection();
		return c.selectSQL(sql);
	}
	
	public void closeDB(){
		try {
			c.closeConnection();
			if(rs!=null){				
				rs.close();				
				rs = null;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
		
}
